
public class Test {
	public static void main(String[] args) {
		BinTree bt = new BinTree();
		bt.insert(10);
		bt.insert(5);
		bt.insert(8);
		bt.insert(3);
		bt.insert(11);
		bt.insert(18);
		
		Visitor visitor = new Visitor(){

			@Override
			public void visit(Node node) {
				System.out.print(node.value+" ");				
			}};
		System.out.print("Inorder:\t");
		bt.getRoot().inOrder(visitor);
		System.out.println();
		System.out.print("Preorder:\t");
		bt.getRoot().preOrder(visitor);
		System.out.println();
		System.out.print("Postorder:\t");
		bt.getRoot().postOrder(visitor);
		System.out.println();
		
		Node key_11 = bt.findNode(11);
		System.out.println(key_11.value);
		Node key_null = bt.findNode(1000);
		if (key_null == null){
			System.out.println("1000 doesn't exist!");
		}
		Node mininum = bt.getMininum();
		System.out.println("Mininum: "+mininum.value);
		Node maxinum = bt.getMaxinum();
		System.out.println("Maxinum:"+maxinum.value+", parented by "+maxinum.parent.value);
		/*boolean deleted_18 = bt.delete(18);
		System.out.println((deleted_18? "deleted " : " can't delete ")+" 18");
		System.out.print("Inorder:\t");
		bt.getRoot().inOrder(visitor);
		System.out.println();*/
		boolean deleted_11 = bt.delete(11);
		System.out.println((deleted_11? "deleted " : " can't delete ")+" 11");
		System.out.print("Inorder:\t");
		bt.getRoot().inOrder(visitor);
		System.out.println();
		boolean deleted_1000 = bt.delete(1000);
		System.out.println((deleted_1000? "deleted " : " can't delete ")+" 1000");
		bt.insert(15);
		bt.insert(20);
		bt.insert(25);
		bt.insert(13);
		bt.insert(22);
		System.out.print("Inorder:\t");
		bt.getRoot().inOrder(visitor);
		System.out.println();
		bt.delete(18);
		System.out.print("Inorder:\t");
		bt.getRoot().inOrder(visitor);
		System.out.println();
		
		Node node_choose = bt.findNode(25);
		System.out.println("parent of "+node_choose.value+ " is "+node_choose.parent.value);
		node_choose = bt.findNode(15);
		System.out.println("parent of "+node_choose.value+ " is "+node_choose.parent.value);
		
		
	}
}
